<script src="jquery-1.10.1.min.js" type="text/javascript"></script>

<script type="text/javascript">
  $(document).ready(function(){
    $('.chk_all').on('click',function(){

      //var countChk = $('.chk').size();

      if(this.checked == true){
        $('.chk').prop('checked',true);
      } else {
        $('.chk').prop('checked',false);
      }


    });
  });
</script>

<input type="checkbox" name="hobbies[]" class="chk_all" />Select All<br>
<hr>
<input type="checkbox" name="hobbies[]" class="chk" />Cricket<br>
<input type="checkbox" name="hobbies[]" class="chk" />Hockey<br>
<input type="checkbox" name="hobbies[]" class="chk" />Badminton<br>
<input type="checkbox" name="hobbies[]" class="chk" />PHP<br>
<input type="checkbox" name="hobbies[]" class="chk" />JAVA<br>
<input type="checkbox" name="hobbies[]" class="chk" />HTML<br>
